#include "UseMutex.h"
#include <random>

UseMutex::UseMutex() {}

void UseMutex::inc() {

	// random n s sleep
	default_random_engine generator;
	uniform_int_distribution<int> distribution(1, 5);

	// simple use, if except will unlock cause dead
	UseMutex::count_mu.lock();
	UseMutex::count++;
	this_thread::sleep_for(chrono::seconds(distribution(generator)));
	UseMutex::count_mu.unlock();

}

uint64_t UseMutex::get_count() {
	return UseMutex::count;
}

UseMutex::~UseMutex() {}

// define static variable
uint64_t UseMutex::count = 0;
mutex UseMutex::count_mu;


